#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include <unistd.h>
#include <sys/un.h>
#include <sys/socket.h>

#define PATH "/home/windy/domainsock"

int main() {
	int sockfd = 0;
	struct sockaddr_un addr;
	
	unlink(PATH);
	addr.sun_family = AF_UNIX;
	strcpy(addr.sun_path, PATH);

	unsigned int len = strlen(addr.sun_path) + \
								sizeof(addr.sun_family);
	sockfd = socket(AF_UNIX, SOCK_DGRAM, 0);
	bind(sockfd, (struct sockaddr*)&addr, len);

	while (1) {
		char recv_buf[20] = {0};
		recvfrom(sockfd, recv_buf, 20, 0, (struct sockaddr*)&addr, &len);
		printf("Recv: %s\n", recv_buf);
	}
	return 0;
}